﻿/**
作者: zhaoweiyong
描述：给JS提供方法
时间: 2017-05-19 16:09:41
**/
package  {
	
	import flash.display.MovieClip;
	import flash.external.ExternalInterface;
	import flash.events.MouseEvent;
	
	public class Demo1Main extends MovieClip {
		
		
		public function Demo1Main() {
			
			// 获取参数
			if(this.loaderInfo.parameters.name1){
				defaultParam.text = this.loaderInfo.parameters.name1 + "\n" +  this.loaderInfo.parameters.name2 +"\n" + this.loaderInfo.parameters.name3;
			}
			
			//提供外部方法
			trace(ExternalInterface);
			if (ExternalInterface.available) {
				ExternalInterface.addCallback("changeContent", changeContent);
			}
			
			//调用js
			btnInvokeJs.addEventListener(MouseEvent.CLICK, clickHandler);
		}
		
		//调用JS
		public function clickHandler(event:MouseEvent):void{
			
			ExternalInterface.call("showDialog", "20170519");
		}
		
		/**
			更改文本
		**/
		public function changeContent(param:String):String{
			
			passParam.text = param;
			return "更改成功";
		}
		
	}
	
}
